<docs>
  ## 编辑个人基本信息
</docs>
<template>
  <div class="wrap">
    <co-form :model="xxjl" :rules="rules" ref="form" label="学习经历">
      <!-- <co-input prop="rxsj" label="入学时间" type="tel"
        v-model="xxjl.rxsj" placeholder="请输入入学时间"></co-input> -->
      <data-picker2 prop="rxsj" label="入学时间"
        v-model="xxjl.rxsj"></data-picker2>
      <!-- <co-input prop="bysj" label="毕业时间" type="tel"
        v-model="xxjl.bysj" placeholder="请输入毕业时间"></co-input> -->
      <data-picker2 prop="bysj" label="毕业时间"
        v-model="xxjl.bysj"></data-picker2>
      <co-input prop="byyx" label="毕业院校"
        v-model="xxjl.byyx" placeholder="请输入毕业院校"></co-input>
      <co-input prop="xxjlbz" label="备注"
        v-model="xxjl.xxjlbz" placeholder="请输入备注"></co-input>
    </co-form>
    <div class="btn-wrap">
      <button class="weui-btn weui-btn_primary" @click.prevent="save" type="button">保存</button>
      <button class="weui-btn weui-btn_default" @click="backBase" type="button">返回</button>
    </div>

  </div>
</template>
<script>
import $ from '@/common/js/axios';
import coForm from 'base/form/form';
import coInput from 'base/form/input';
import coSelect from 'base/form/select';
import { validator } from 'common/js/valid';
import coLevelPicker from 'base/form/levelPicker';
import dataPicker2 from 'base/form/dataPicker2';

export default {
  name: 'editSchool',
  components: { coForm, coInput, coSelect, coLevelPicker, dataPicker2 },
  data() {
    return {
      xxjl: {
        grqzid: '',
        xxjlid: '',
        rxsj: '', // 入学时间
        bysj: '', // 毕业时间
        byyx: '', // 毕业院校
        xxjlbz: '', // 备注
        ywcz: '' // 业务操作，（1：新增，2：修改，0：删除）
      },
      rules: {
        rxsj: validator('11,"full","入学时间",false'),
        bysj: validator('48,full,"毕业时间",false'),
        byyx: validator('168,"full","毕业院校",false'),
        xxjlbz: validator('32,"full","备注",true')
      }
    };
  },
  methods: {
    save() {
      this.$refs.form.validate(() => {
        this.POST_save();
      });
    },
    /* 保存学习信息修改 */
    POST_save() {
      this.$loading = true;
      this.$http.post('/url/post/grgl_xxjlBc', this.xxjl).then(res => {
        const resData = res.returnData;
        this.$alert(resData.message, () => {
          const code = +resData.executeResult;
          if (code) {
            this.backBase();
          }
        });
      }).finally(() => {
        this.$loading = false;
      });
    },
    /* 返回基础信息 */
    backBase() {
      this.$router.go(-1);
    }
  },
  created() {
    var xxjl = this.$route.query;
    Object.keys(this.xxjl).forEach(item => {
      if (xxjl[item]) {
        this.xxjl[item] = xxjl[item];
      }
    });
  }
};
</script>
<style scoped lang="scss">
@import '~common/scss/var.scss';
.wrap {
  .btn-wrap {
    display: flex;
    .weui-btn {
      margin: $margin-base auto;
      flex: 0 1 47%;
    }
  }
}
</style>
